
package mamayukero.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
import mamayukero.problem.environment.Environment;


public class debug extends JPanel {
    public JFrame frame;
    
    public debug() {
        super();
        frame = new JFrame();
        setLayout(null);
        frame.setSize(600,600);
        frame.add(this);
        frame.setVisible(true);
    }
    
    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        for (int i = 0; i < Environment.map.row; i++) {
            for (int j = 0; j < Environment.map.col; j++) {
                g2d.setColor(Environment.map.block[i][j]? Color.GREEN : Color.RED);
                g2d.fillRect((i*(550/Environment.map.row))+10, (j*550/Environment.map.col)+10, (550/Environment.map.row)-10, (550/Environment.map.col)-10);
            }
            //gambar pabrik
            g2d.setColor(Color.BLACK);
            g2d.fillOval(((Environment.map.factory.getLocation().x*(550/Environment.map.row))+10), ((Environment.map.factory.getLocation().y*(550/Environment.map.row))+10), 
                    (550/Environment.map.row)-10, (550/Environment.map.col)-10);
        }
    }
    
    public static void main(String[] args) {
        //Environment.initMap();
        //Environment.loadFile("input.txt");
        //Environment.matrix.printMatrix();
        //Environment.map.printMap();
        Environment.Reset();
        Environment.drawMap();
        //AStar astar = new AStar(Environment.map);
        //astar.solve(new Point(0,0), new Point(2,2)).toString();
        debug d = new debug();
        System.out.println(Environment.map.factory.toString());
    }
    
}
